<template>
  <div>
    <div
      class="ball"
      :style="{ color: activeColor, fontSize: fontSize + 'px' }"
    >
      球
    </div>
    <div style="margin: 20px 0">
      <button @click="changeColor">改变颜色</button>
    </div>
    <div :style="[baseStyles, overridingStyles]">正方形</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      fontSize: 30,
      activeColor: "blue",
      baseStyles: {
        backgroundColor: "lightblue",
        width: "100px",
        height: "100px",
      },
      overridingStyles: {
        border: "2px solid red",
        fontSize: "20px",
        lineHeight: "100px",
        textAlign: "center",
      },
    };
  },
  methods: {
    changeColor() {
      this.activeColor = this.activeColor === "red" ? "blue" : "red";
    },
  },
};
</script>

<style lang="scss" scoped>
.ball {
  width: 100px;
  height: 100px;
  line-height: 100px;
  text-align: center;
  border-radius: 50%;
  background-color: lightgray;
}
</style>
